package org.achao.conttoller;

import org.achao.pojo.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author achao
 * @description 测试
 * @date 2023/10/10 21:25
 */
@RestController
@RequestMapping("/test")
public class TestController {

    public static final List<User> userList = new ArrayList<>();

    static {
        for (int i = 10; i < 20; i++) {
            userList.add(User.builder().name("test" + i).sex("1").age(i).build());
        }
    }

    @GetMapping("/setAge")
    public String setAge(int age) {
        User user = new User();
        user.setAge(age);
        user.setSex("1");
        user.setName("abc");

        return "ok";
    }

    @GetMapping("/getUsers")
    public List<User> getUserList() {
        return userList;
    }
}
